home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mcwint20.zip / QDEMO20.C < prev    next >
Text File  |  1988-01-11  |  12KB  |  335 lines

  1. #define USE_LOCAL
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <time.h>
  6. #include <dos.h>
  7. #include <conio.h>
  8. #include <w1.h>
  9. #include <windprot.h>
  10. #include <color.h>
  11.  
  12. #define WAIT 15000
  13. /*===============================================================================*/
  14. /*  Qdemo20.c - Demonstration program for Qwik write utilities  ver 2.0, 1-1-88      */
  15. /*  Demo has been programmed for All Cards and any column mode.  If you want to  */
  16. /*  try 40 column mode, set crtcolumns to 40 in main. This does not set your     */
  17. /*  machine to 40 column mode. This must be done by the DOS mode command.        */
  18. /*                                                                               */
  19. /* AUTHORS: Turbo Pascal version -- (C) 86,87 Jim H. Lemay                       */
  20. /*          Turbo C version -- (C) 1987,1988 Mike Mlachak                             */
  21. /*          Microsoft version -- (C) 1987,1988 Mike Mlachak
  22. /* DATE:    6-1-87                                                               */
  23. /* VERSION: 2.0                                                                  */
  24. /* REVISIONS: Modified source to use new function 2.0 calls 1-1-88
  25. /* COMMENTS: Must be compiled in SMALL model and linked with T1xwin20.lib          */
  26. /*===============================================================================*/
  27.  
  28. typedef char str80[80];
  29.  
  30.     int          row, rows, col, cols, ctr, step, rstep, colmax, count,
  31.                  attrib, i, j, crtcols;
  32.     int          hidecursor, oldcursor, fgrnd, bgrnd;
  33.     int          brdrattr, wndwattr;
  34.     char         savedblock[4000], popupblock[4000];
  35.     int          blkrow, blkcol;
  36.     int          crtcolumns;               /*  number of CRT columns  */
  37.     int          tattr;
  38.     int          coll[3], colr[3];
  39.     char         strng[75], numstr[75];
  40.     double       rnum;
  41.  
  42.     int random(int);
  43.  
  44.  
  45.    static str80 data[9] = {
  46.        "1",
  47.        "22",
  48.        "333",
  49.        "Qwik-Write Utilities",
  50.        "Odd  Length",
  51.        "Even  Length",
  52.        "18 characters wide",
  53.        "19 characters width",
  54.        "Margin to Margin width"};
  55.  
  56. static str80 vers = "Qwik-Write Utilities (Version 2.0)";
  57. void main(void)
  58. {
  59. /*  --- Set up data ---  */
  60.   qinit(); /*  << <<  Required intializing statement !!  */
  61.   crtcolumns = 80;
  62.   crtcols = crtcolumns;
  63.   hidecursor = 8192;
  64.  
  65. /*  --- Initial screen ---  */
  66.   oldcursor = cursorchange(hidecursor);
  67.   qfill(1, 1, 25, crtcols, (BLUE << 4) + WHITE, ' '); /*   Clear Screen  */
  68.   qwritec(11, 1, crtcols, (BLUE << 4) + YELLOW, vers);
  69.   qwritec(13, 1, crtcols, -1, "Your screen is about to explode.");
  70.   qwritec(14, 1, crtcols, -1, "Hold on to your seat ...");
  71.   wsleep(6*18);
  72.  
  73. /*  --- Explosion of Boxes ---  */
  74.   qfill(11, 1, 4, crtcols, -1, ' '); /*   Clear Lines  */
  75.   qattr(1, 1, 25, crtcols, LIGHTGRAY << 4); /*   Change screen attribute  */
  76.   ctr = crtcols / 2;
  77.   for (step = 2; step <= ctr - 2; step++) {
  78.      if (step > 24)
  79.         rstep = 12;
  80.      else
  81.         rstep = step >> 1;
  82.      for (count = 1; count <= 20; count++) {
  83.         row = 13 - rstep + random(rstep + 2);
  84.         rows = rstep;
  85.         cols = rstep + rstep + (rstep >> 2);
  86.         if (step <= 24)
  87.            col = ctr - cols + random(cols + 1);
  88.         else
  89.            col = ctr - 1 - step + random(step + step - 22);
  90.       fgrnd = random(16);
  91.       bgrnd = random(8);
  92.       if (bgrnd == fgrnd)
  93.          fgrnd = fgrnd + 1;
  94.       attrib = (bgrnd << 4) + fgrnd;
  95.       qfill(row,col,row,cols,attrib,'▓');
  96.     }  /* for count = 1*/
  97.   } /* for step = 2,..etc */
  98.  
  99.   qfillc(10, 1, crtcols, 6, 34, RED << 4, ' ');
  100.   qfillc(11, 1, crtcols, 4, 30, BROWN << 4, ' ');
  101.   tattr = (RED << 4) + YELLOW;
  102.   qwritec(12, 1, crtcols, tattr, vers);
  103.   qwritec(13, 1, crtcols, tattr, "Turbo-C (1.0)");
  104.  
  105.   /*  --- Save Screen for Page Demo ---  */
  106.   if (maxpage > 0)
  107.   {
  108.     qstore(1, 1, 25, crtcols, savedblock);
  109.     qwritepage(1);
  110.     qrestore(1, 1, 25, crtcols, savedblock);
  111.     qwritepage(0);
  112.   }
  113.   /*  --- End of Save Screen ---  */
  114.   wsleep(4*18);
  115.   tattr = (BLUE << 4) + WHITE;
  116.   qwritec(6, 1, crtcols, tattr, " qwrite will write with new attributes ");
  117.   qwritec(7, 1, crtcols, tattr, " that you specify direct to the screen.");
  118.   wsleep(5*18);
  119.   qwritec(18, 1, crtcols, -1, " qwrite will also use existing attributes ");
  120.   qwritec(19, 1, crtcols, -1, "    when you do not even know or care.    ");
  121.                         /*  highlight the word 'existing'  */
  122.   qattrc(18, 6, crtcols + 5, 1, 10, (LIGHTRED << 4) + WHITE);
  123.   wsleep(6*18);
  124.   qwritec(21, 1, crtcols, tattr, " Say Goodbye to this screen. ");
  125.   wsleep(4*18);
  126.   /*  --- Disintigrate Screen ---  */
  127.  
  128.   for (i = 1; i <=7500; i++) {
  129.     row = random(25) +1;
  130.     col = random(crtcols) + 1;
  131.     qfill(row,col,1,1,BLACK, ' ');
  132.   }
  133.  
  134. /*  --- Qwrite with Reals Demo ---  */
  135.   qfill(1, 1, 25, crtcols, YELLOW, ' '); /*   Clear Screen  */
  136.   qwritec(2, 1, crtcols, -1, "qwrite with TURBO-C's sprintf will write");
  137.   qwritec(3, 1, crtcols, -1, "reals and integers faster:");
  138.   wsleep(6*18);
  139.   rnum = 1.2345678901;
  140.   for (col = 0; col <= (crtcols / 20) - 1; col++)  {
  141.      for (row = 5; row <= 24; row++) {
  142.         rnum = rnum + 20.0;
  143.         sprintf(numstr,"%e",rnum);
  144.         qwrite(row, col * 20 + 4, -1, numstr);
  145.      }
  146.   }
  147.   wsleep(7*18);
  148.  
  149. /*  --- Centering Demo ---  */
  150.   qfill(1, 1, 25, crtcols, LIGHTGRAY << 4, ' '); /*   Clear Screen  */
  151.   qwritec(2, 1, crtcols, -1, "qwritec  will automatically");
  152.   qwritec(3, 1, crtcols, -1, "center your data ...");
  153.   qwritec(4, 1, crtcols, -1, "(ODD breaks are shifted to the left.)");
  154.   wsleep(6*18);
  155.  
  156.   /*  - Set up columns for varying column modes -  */
  157.   coll[1] = 1;
  158.   colr[1] = crtcols;
  159.   if (crtcols < 80) {
  160.      coll[0] = coll[1];
  161.      coll[2] = crtcols / 2;
  162.      colr[0] = colr[1];
  163.      colr[2] = crtcols / 2;
  164.   }
  165.   else {
  166.      coll[0] = 3;
  167.      colr[0] = 26;
  168.      coll[2] = crtcols - 14;
  169.      colr[2] = crtcols - 14;
  170.   }
  171.  
  172.   qwritec(7, coll[0], colr[0], -1, "between margins ...");
  173.   qbox(8, (coll[0] + (colr[0] >> 1)) - 14, 15, 26, WHITE, LIGHTGRAY, doublebrdr);
  174.   wsleep(4*18);
  175.   for (row = 11; row <= 19; row++)
  176.      qwritec(row, coll[0], colr[0], -1, data[row - 11]);
  177.   wsleep(4*18);
  178.  
  179.   qwritec(7, coll[1], colr[1], -1, "between two columns ...");
  180.   qfillc(9, coll[1], colr[1], 13, 24, YELLOW, ' '); /*   Clear window  */
  181.   for (row = 9; row <= 21; row++)
  182.      qwritec(row, coll[1], colr[1], -1, "><"); /*   Show two columns   */
  183.   wsleep(4*18);
  184.   for (row = 11; row <= 19; row++)
  185.      qwritec(row, coll[1], colr[1], LIGHTRED, data[row - 11]);
  186.   wsleep(4*18);
  187.  
  188.   qwritec(7, coll[2], colr[2], -1, "or on a center line ...");
  189.   qfillc(8, coll[2], colr[2], 15, 27, LIGHTGRAY << 4, ' '); /*   Clear window  */
  190.   for (row = 9; row <= 21; row++) /*   Show center line   */
  191.      qwritec(row, coll[2], colr[2], (LIGHTGRAY << 4) + WHITE, "|");
  192.   wsleep(4*18);
  193.   for (row = 11; row <= 19; row++)
  194.      qwritec(row, coll[2], colr[2], -1, data[row - 11]);
  195.   wsleep(7*18);
  196.  
  197. /*  --- Qfill Demo ---  */
  198.   qfill(1, 1, 25, crtcols, WHITE, ' '); /*   Clear Screen  */
  199.   qwritec(2, 1, crtcols, -1, "qfill as well as qattr can fill");
  200.   qwritec(3, 1, crtcols, -1, "your screen in several ways.");
  201.   wsleep(5*18);
  202.  
  203.   qwritec(7, 1, crtcols, -1, "by rows ...");
  204.   wsleep(4*18);
  205.   for (row = 9; row <= 24; row++)
  206.      qfill(row, 2, 1, crtcols - 2, 9 + row, (char)(row + 56));
  207.   wsleep(5*18);
  208.  
  209.   qfill(7, 1, 19, crtcols, WHITE, ' '); /*   Clear Lines  */
  210.   qwritec(7, 1, crtcols, -1, "by columns ...");
  211.   wsleep(4*18);
  212.   for (col = 2; col <= crtcols - 2; col++)
  213.      qfill(9, col, 16, 1, 16 + col, (char)(col + 63));
  214.   wsleep(5*18);
  215.  
  216.   qfill(7, 1, 19, crtcols, WHITE, ' '); /*   Clear Lines  */
  217.   qwritec(7, 1, crtcols, -1, "or by row-by-column blocks ...");
  218.   wsleep(4*18);
  219.   qfill(9, 2, 16, crtcols - 2, (BLUE << 4) + YELLOW, '!');
  220.   wsleep(6*18);
  221.  
  222. /*  --- Qbox demo ---  */
  223.   qfill(1, 1, 25, crtcols, LIGHTGRAY << 4, ' '); /*   Clear Screen  */
  224.   qwritec(2, 1, crtcols, -1, "qbox is an application procedu